package com.flame.user.exception;

import java.text.MessageFormat;

import com.flame.core.exception.ExceptionLevel;
import com.flame.core.exception.ExceptionMessage;

/**
 * flame_user_account 用户账号表
 *
 * @author 吴欣童
 * @since 2022-12-14 16:06:58
 */
public enum UserExceptionMessage implements ExceptionMessage {
    ACCOUNT_EXIST("100001", "添加失败，用户已存在", ExceptionLevel.INFO),
    ACCOUNT_NOT_EXIST("100001", "修改失败，用户不存在", ExceptionLevel.INFO),
    OLD_PASSWORD_NOT_EQUALS("100001", "修改失败，旧密码错误", ExceptionLevel.INFO),
    MENU_EXIST("100004", "菜单【{0}】已存在", ExceptionLevel.INFO),
    ROLE_EXIST("100001", "添加失败，角色已存在", ExceptionLevel.INFO),
    USERINFO_EXIST("100001", "添加失败，用户已存在", ExceptionLevel.INFO),
    NEW_PASSWORD_TOO_LONG("100001", "修改失败，新密码长度不得大于{0}", ExceptionLevel.INFO),
    NEW_PASSWORD_TOO_SHORT("100001", "修改失败，新密码长度不得小于{0}", ExceptionLevel.INFO),
    NEW_PASSWORD_STRENGTH_NOT_HIGH("100001", "修改失败，新密码中必须包含大写字母、小写字母、数字、特殊字符，至少3种", ExceptionLevel.INFO),
    NEW_PASSWORD_STRENGTH_NOT_MIDDLE("100001", "修改失败，新密码中必须包含大写字母、小写字母、数字、特殊字符，至少2种", ExceptionLevel.INFO),
    NEW_PASSWORD_STRENGTH_NOT_LOW("100001", "修改失败，新密码中必须包含大写字母、小写字母、数字、特殊字符，至少1种", ExceptionLevel.INFO),
    ORGINFO_EXIST("100001", "添加失败，机构已存在", ExceptionLevel.INFO);

    private String code;

    private String message;

    private ExceptionLevel level;

    UserExceptionMessage(String code, String message, ExceptionLevel level) {
        this.code = code;
        this.message = message;
        this.level = level;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public String getMessage(Object... args) {
        return MessageFormat.format(this.message, args);
    }

    @Override
    public ExceptionLevel getLevel() {
        return level;
    }
}
